package com.allin.plugin2;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.allin.pluginlibrary.AppConstants;
import com.allin.pluginlibrary.activity.BasePluginActivity;
import com.allin.pluginlibrary.MyPlugins;

/**
 * ${CLASS} class
 *
 * @author tzy
 * @date 2021/03/08
 */
public class MainActivity extends BasePluginActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //startActivity，插件外跳转
        Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String plugin1DexPath = MyPlugins.plugins.get("plugin1.apk");

                Intent intent = new Intent(AppConstants.PROXY_VIEW_ACTION);
                intent.putExtra(AppConstants.EXTRA_DEX_PATH, plugin1DexPath);
                intent.putExtra(AppConstants.EXTRA_CLASS, "com.allin.plugin1.SecondActivity");
                startActivity(intent);
            }
        });

        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AppConstants.PROXY_VIEW_ACTION);
//                intent.putExtra(AppConstants.EXTRA_DEX_PATH, dexPath);
                intent.putExtra(AppConstants.EXTRA_CLASS, "com.allin.plugin2.ActivityA");
                intent.putExtra("username", "baobao");
                startActivity(intent);
            }
        });
    }
}